package com.cn.lf.wx.dacs.bussiness.author.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.cn.lf.wx.dacs.bussiness.author.serviceImpl.HisServiceImpl;
import com.cn.lf.wx.dacs.bussiness.author.utils.Main;
import com.cn.ym.log.Log;

@RestController("apiController")
@RequestMapping("/api")
public class ApiController extends Base {
	@Autowired
	private HisServiceImpl hisServiceImpl;

	@GetMapping("/getByTimes")
	public void getByTimes(String startTime, String endTime) throws IOException {
		Log.info("start---" + startTime + "-----end" + endTime);
		new Main().main(startTime, endTime);
	}

	@GetMapping("/getBybah")
	public void getBysfzh(String bah) throws IOException {
		String[] bahs = bah.split(",");
		for (String item : bahs) {
			Log.info("bah---" + item);
			new Main().getBybah(item);
		}
	}

	@GetMapping("/getAll")
	public void getAll() throws IOException {
		List<Map<String, Object>> list = hisServiceImpl.getAll();
		for (Map<String, Object> item : list) {
			Log.info("bah---" + item);
			new Main().getBybah(item.get("ZYHM").toString());
		}
	}

	@GetMapping("/test")
	public String test() throws IOException {
		return hisServiceImpl.test();
	}

//	@GetMapping("/getTime")
//	public String getTime(String bah) throws IOException {
//		return hisServiceImpl.selectByDate();
//	}

//	// 显示图片
//	@Transactional
//	@RequestMapping("/showImg")
//	public void showImg(HttpServletResponse response,String imgurl) throws IOException {
//		this.hisServiceImpl.viewFile(response, imgurl);
//	}

}
